package com.forlove.app.manager.async;

import android.content.Context;
import android.support.v4.content.AsyncTaskLoader;

import com.forlove.app.manager.ContactsManager;
import com.forlove.app.qselect.login.entity.ContactsInfoEntity;

import java.util.List;

/**
 * Created by yjl on 2017/10/21.
 */

public class LoadContactsAsync extends AsyncTaskLoader<List<ContactsInfoEntity>> {
    public static final int ASYNC_ID = 20000;
    public List<ContactsInfoEntity> data;

    public LoadContactsAsync(Context context) {
        super(context);
    }

    @Override
    public List<ContactsInfoEntity> loadInBackground() {
        data = ContactsManager.getContectInfo(getContext());
        return data;
    }

    @Override
    protected void onStartLoading() {
        super.onStartLoading();
        if (data == null) {
            forceLoad();
        } else {
            deliverResult(data);
        }
    }

}
